package com.shujia.spark.core

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object Demo6Sample {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("map")
    conf.setMaster("local")

    val sc = new SparkContext(conf)


    //读取学生表的数据
    val studentsRDD: RDD[String] = sc.textFile("data/students.txt")

    /**
     * sample:可以从数据中抽样一部分数据
     *
     */
    val sample: RDD[String] = studentsRDD.sample(withReplacement = true, 0.1)


    sample.foreach(println)


  }

}
